#delimit; 
clear all;
set more off;

capture log close;

log using log/atusrost_0321.log, replace;
 
import delimited
 tucaseid
 tulineno
 terrp
 teage
 tesex
 using c:\atus\atus0321\atusrost-0321\atusrost_0321.dat, stringcols(1) ;
 
label variable teage "Edited: age";
label variable tucaseid "ATUS Case ID (14-digit identifier)";
label variable tulineno "ATUS person line number";
label variable terrp "Edited: how is this person related to you?";
label variable tesex "Edited: sex";

gen age=.;
replace age=teage if (terrp==18 | terrp==19);
gen sex=.;
replace sex=tesex if (terrp==18 | terrp==19);
su;
sort tucaseid;
keep if tulineno==1;
keep tucaseid tulineno age sex;
su;
save work/atusrost_0321.dta, replace;   

log close;